void phone_vs(float4 objPos           : POSITION,
              float3 inNormal         : NORMAL,
              out float4 projPos      : POSITION,
              out float3 outPos       : TEXCOORD0,
              out float3 outNormal    : TEXCOORD1
              uniform float4x4 modelViewProj
              )
{
   projPos     = mul(objPos, modelViewProj);
   outPos      = objPos;
   outNormal   = inNormal;
}

void phone_ps(float3         objPos     : TEXCOORD0, 
              float3         inNormal   : TEXCOORD1,
              out float4     finalColor : COLOR,
              uniform float4 globalAmbient,
              uniform float4 diffuseColor, 
              uniform float4 specularColor,
              uniform float3 lightPos, 
              uniform float3 eyePos, 
              uniform float4 kEmissive,
              uniform float4 kAmbient,
              uniform float4 kDiffuse,
              uniform float4 kSpecular,
              uniform float  shininess)
{
    float3 pos = objPos;
    float3 normal   = normalize(inNormal);
    float3 lightDir = normalize(lightPos - pos);
    
    float3 emissive = kEmissive.rgb;
    float3 ambient  = kAmbient.rgb * globalAmbient.rgb;
    
    float diffuseLight = max(dot(normal, lightDir), 0);
    float3 diffuse = kDiffuse.rgb * diffuseColor.rgb * diffuseLight;
    
    float specularLight = 0;
    if(diffuseLight > 0 )
    {
       float3 lookDir = normalize(eyePos - pos);
       float3 h = normalize(lightDir + lookDir);
       specularLight = pow(max(dot(normal, h), 0), shininess);
    }
    float3 specular = kSpecular.rgb * specularColor.rgb * specularLight;
    
    finalColor.rgb = emissive + ambient + diffuse + specular;
    finalColor.a = 1;   
}

technique PhoneLight1
{
    pass P0
    {          
		ZENABLE = true;
        VertexShader = compile vs_2_0 phone_vs();
        PixelShader  = compile ps_2_0 phone_ps();
    }
}
